<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gift extends Admin_Controller
{
	private static $data = array();
	protected $models=['gift_model'];
	public function __construct()
	{
		parent::__construct();
	}

	
	//礼物列表入口
	public function index(){
	    $gift=$this->gift_model->getWhere([]);
	    self::$data['gift']=$gift;
	    $this->load->view('admin/gift/list.html',self::$data);
	}
	
	//添加分类入口
	public function addgift_index(){
	    $this->load->view('admin/gift/add.html');
	}
	//添加分类
	public function addgift(){
	    $data=$this->input->post();
	    $data=unsetArray_key($data,'file');
	    if (isset($data['giftId'])&&!empty($data['giftId'])){
	        $res=$this->gift_model->updateWhere(['giftId'=>$data['giftId']],$data);
	    }else{
	        $res=$this->gift_model->insert($data);
	    }
	    
	    if($res) echo 200;
	}
	//删除分类
	public function delgift(){
	    $giftId=$this->input->post('giftId');
	    $res=$this->gift_model->delWhere_logic(['giftId'=>$giftId]);
	    if ($res) echo 200;
	}
	
	
	
}
/* End of file Login.php */